

<%@ page import="com.cgah.Listing" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'listing.label', default: 'Listing')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav"><span class="spacer"></span>
            %{--<span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>--}%
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${listingInstance}">
            <div class="errors">
                <g:renderErrors bean="${listingInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${listingInstance?.id}" />
                <g:hiddenField name="version" value="${listingInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="name"><g:message code="listing.name.label" default="Name" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" maxlength="64" value="${listingInstance?.name}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="endDateTime"><g:message code="listing.endDateTime.label" default="End Date Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'endDateTime', 'errors')}">
                                    <g:datePicker name="endDateTime" precision="day" value="${listingInstance?.endDateTime}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="startingBidPrice"><g:message code="listing.startingBidPrice.label" default="Starting Bid Price" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'startingBidPrice', 'errors')}">
                                    <g:textField name="startingBidPrice" value="${fieldValue(bean: listingInstance, field: 'startingBidPrice')}" />
                                </td>
                            </tr>
                        
%{--
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="seller"><g:message code="listing.seller.label" default="Seller" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'seller', 'errors')}">
                                    <g:select name="seller.id" from="${com.cgah.Customer.list()}" optionKey="id" value="${listingInstance?.seller?.id}"  />
                                </td>
                            </tr>
--}%

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="description"><g:message code="listing.description.label" default="Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" cols="40" rows="5" value="${listingInstance?.description}" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="winner"><g:message code="listing.winner.label" default="Winner" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'winner', 'errors')}">
                                    <g:select name="winner.id" from="${com.cgah.Customer.list()}" optionKey="id" value="${listingInstance?.winner?.id}" noSelection="['null': '']" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="bids"><g:message code="listing.bids.label" default="Bids" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: listingInstance, field: 'bids', 'errors')}">
                                    
                                    <ul>
                                    <g:each in="${listingInstance?.bids?}" var="b">
                                        <li><g:link controller="bid" action="show" id="${b.id}">${b?.encodeAsHTML()}</g:link></li>
                                    </g:each>
                                    </ul>
                                    <g:link controller="bid" action="create" params="['listing.id': listingInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'bid.label', default: 'Bid')])}</g:link>

                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
